Add maxViaCount constraint to trace props - #781
Conversation
| test("supports limiting the maximum number of PCB vias", () => { | ||
| const raw: TraceProps = { | ||
| from: "A", | ||
| to: "B", | ||
| maxViaCount: 0, | ||
| } | ||
|
|
||
| const parsed = traceProps.parse(raw) | ||
|
|
||
| expect(parsed.maxViaCount).toBe(0) | ||
| expect(() => traceProps.parse({ ...raw, maxViaCount: -1 })).toThrow() | ||
| expect(() => traceProps.parse({ ...raw, maxViaCount: 1.5 })).toThrow() | ||
| }) |
There was a problem hiding this comment.
The style guide states that a *.test.ts file may have AT MOST one test(...) call. This new test block ("supports limiting the maximum number of PCB vias") is being added to trace.test.ts, which already contains at least one other test(...) (e.g., the "accepts start/end aliases for trace endpoints" test at line 92/106, and others visible earlier in the file). Once a file has more than one test, the tests must be split into multiple numbered files — for example, trace1.test.ts, trace2.test.ts, etc. Please move this new test into its own numbered file (e.g., trace2.test.ts or an appropriate number) to comply with the one-test-per-file rule.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
What changed
maxViaCountprop to<trace>Why
RF, clock, and other critical PCB traces often need an explicit via budget. For example,
maxViaCount={0}lets a design state that an antenna matching or feed trace must remain on one layer instead of relying on autorouter heuristics.The prop is optional and has no default, so existing routing behavior is unchanged.
Follow-up implementation
Core should pass this constraint into circuit-json, and the autorouter should reject routes whose via count exceeds the limit. If no valid route exists, routing should fail with a constraint-specific error instead of silently inserting a via.
Validation
bun test tests/trace.test.tsbun run typecheckbun run buildbun run format:check